<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我是一阵风直播</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
        #aui-header{position: fixed;}
    </style>
</head>
<body>
    <header class="aui-bar aui-bar-nav" id="aui-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="goBack()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">创建直播间 </div>
    </header>

    <div class="aui-content aui-margin-b-15" id="my-video-main">
        <ul class="aui-list aui-media-list">
            <li class="aui-list-item aui-list-item-middle">
                <div class="aui-media-list-item-inner">
                  <div class="aui-list-item-label aui-border-r aui-text-center">直播间标题</div>
                  <div class="aui-list-item-input aui-padded-l-10">
                      <input type="text"  placeholder="输入标题" id="login_name" >
                  </div>
                </div>
            </li>

        </ul>
    </div>
    <section class="aui-content-padded login-sub">
        <div class="aui-btn aui-btn-block aui-btn-info" tapmode onclick="fnLogin()">开始直播</div>
    </section>
</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript" src="../script/common.js" ></script>
<script type="text/javascript">
apiready = function () {
    fixStatusBar();
    $api.css($api.byId('my-video-main'),'margin-top:'+headerHeight+'px;');
    api.parseTapmode();
    var is_login = $api.getStorage('isLogin');
    fnOpenMainFrame(is_login);
}

function fnLogin(){
  var login_name =  $api.val($api.byId('login_name'));
    var userid= $api.getStorage('userid');
  $api.post(baseUrl+'live/live/creatroom',{
  body: 'String',values:{title:login_name,user_id:userid}
},function(ret){

  rtmp_url = ret;
  if(rtmp_url != '' && rtmp_url != undefined && rtmp_url != null){
    if(rtmp_url.indexOf("rtmp://") == -1){
        _WXUI.alert('仅支持rtmp流');
        return ;
    }
  }
  var data = {
      rtmp_url:rtmp_url,
      resolution:720,
      direction:0
  };


  //查询我的直播间
  api.ajax({
    url: "https://www.qiersan.com/live/live/my_video",
    method: 'post',
    data: {
      'values':{
        "user_id":userid
      }
    }
  },function(ret,err){
    if(ret.code==1){
      $api.setStorage('creattime', ret.data.created_at);
      $api.setStorage('title', ret.data.title);
      $api.setStorage('rid', ret.data.rid);

    }
    //console.log($api.jsonToStr(ret));

  });
  $api.setStorage('pushurl', ret);
  openFrm('video_push_frm',data);
},'text');

}
</script>
</html>
